package miku.firstgame.net.pack
{
	import flash.utils.ByteArray;

	import miku.firstgame.constrants.ProtocalConstants;
	import miku.firstgame.net.ByteArrayEx;

	public class LoginRequestPack extends AbstractRequestPack
	{

		public var username:String;
		public var password:String;

		public function LoginRequestPack()
		{
			super();
		}

		override public function encode():ByteArray
		{
			var data:ByteArrayEx = new ByteArrayEx();
			data.position = 4;
			data.writeShort(tag);
			data.writeShort(0);

			//body
			data.writeString(username);
			data.writeString(password);
			data.position = 0;
			data.writeUnsignedInt(data.length - 4);
			data.position = 0;
			return data;
		}

		override public function get tag():int
		{
			return ProtocalConstants.LOGIN;
		}
	}
}
